package practice;

import java.util.InputMismatchException;
import java.util.Scanner;

public class practice02 {
    public static void main(String[] args) {
        //f0();//关键方法
//        f1();
//        f2();
        f3();
    }

    private static void f3() {//throws方法上抛异常
        try {
            f2();
        }catch (Exception e){
            System.out.println("请正确输入数字");
        }
    }

    private static void f2() throws  Exception{//throws方法抛出异常
        f0();
    }

    private static void f1() {//try catch方法捕获异常
        try {
            f0();
        }catch (ArithmeticException e){
            System.out.println("除数不能为0！");
        }catch (InputMismatchException e){
            System.out.println("请输入整数");
        }catch (Exception e){
            System.out.println("请正确输入数字");
        }
    }

    private static void f0() {
        System.out.println("请输入第一个数");
        int a=new Scanner(System.in).nextInt();
        System.out.println("请输入第二个数");
        int b=new Scanner(System.in).nextInt();
        System.out.println(a/b);
    }
}
